<{script src="formplus.js" app="site"}>

<{if $mini_passport}>
<div class="mini-dialog-close close">X</div>
<{/if}>
<div>
  <form method="post" action='<{link app=b2c ctl='site_passport'  act='create' args01=$next_url }>
    ' class='signupform'>
    <div >
      <h4><{t}>用户注册<{/t}></h4>
      <div class="intro">
        <div class="customMessages">
          <!--register_message-->
        </div>
      </div>
      <div class="loginbox">
        <input name="forward" type="hidden" value="<{$options.url}>">
        <ul>
          <li>
            <label><i>*</i><{t}>用户名：<{/t}></label>
            <div class="floatdiv">
              <input type="text" class="inputstyle _x_ipt " name="pam_account[login_name]" vtype="required"  id="reg_user" maxlength="50" onchange="nameCheck(this)">
              <span></span></div>
          </li>
          <li>
            <label><i>*</i><{t}>密码：<{/t}></label>
            <div class="floatdiv"><{input class="inputstyle" name="pam_account[login_password]" type="password" vtype="required" id="reg_passwd"}></div>
          </li>
          <li>
            <label><i>*</i><{t}>确认密码：<{/t}></label>
            <div class="floatdiv"><{input class="inputstyle" name="pam_account[psw_confirm]" type="password" vtype="required" id="reg_passwd_r"}></div>
          </li>
          <li>
            <label><i>*</i><{t}>电子邮箱：<{/t}></label>
            <div class="floatdiv"><{input vtype="email&&required"  name="contact[email]" id="reg_email" class="inputstyle _x_ipt" onchange="emailCheck(this)"}><span></span></div>
          </li>
          <{foreach from=$attr item=item name="item" key='row'}>
          <li>
            <label><{if $item.attr_required eq 'true'}><em>*</em><{/if}><{$item.attr_name}></label>
            <div class="floatdiv"> <{if $item.attr_type =='date'}>
              <{if $item.attr_value != '0-0-0'}>
              <{if $item.attr_required eq 'true'}>
              <{input class="cal" type='date' vtype="required&&date" name=$item.attr_column value=$item.attr_value}>
              <{else}>
              <{input class="cal" type='date' name=$item.attr_column value=$item.attr_value}>
              <{/if}>
              <{else}>
              <{if $item.attr_required eq 'true'}>
              <{input class="cal" type="date" vtype="required&&date" name=$item.attr_column}>
              <{else}>
              <{input class="cal" vtype="date" name=$item.attr_column}>
              <{/if}>
              <{/if}>
              <{/if}>
              
              <{if $item.attr_type =='region'}>
              <{input app=ectools type="region" name=$item.attr_column value=$item.attr_value }>
              <{/if}>
              
              <{if $item.attr_type =='gender'}>
              <{input type='gender' name=$item.attr_column value=$item.attr_value }>
              <{/if}>
              
              <{if $item.attr_type =='select'}> <select name='<{$item.attr_column}>' <{if $item.attr_required eq 'true'}>class='_x_ipt' vtype='required'<{/if}>> <option value='' <{if $item.attr_value == ''}>selected='true'<{/if}>><{t}>请选择<{/t}>
              </option>
              <{foreach from=$item.attr_option item=option name="option"}> <option value='<{$option}>' <{if $item.attr_value == $option}>selected='true'<{/if}>><{$option}>
              </option>
              <{/foreach}>
              </select>
              <{/if}>
              
              <{if $item.attr_type =='checkbox'}>
              <{foreach from=$item.attr_option item=checkbox name="checkbox" }>
              <input type='checkbox' name=box:<{$item.attr_column}>
              []" value='<{$checkbox}>' <{foreach from=$item.attr_value item=checkboxvalue name="checkboxvalue" }>
              <{if $checkboxvalue==$checkbox}>
              checked ='true' 
              <{/if}>
              <{/foreach}>>
              <label><{$checkbox}></label>
              <br/>
              <{/foreach}>
              <input type='hidden' name='<{$item.attr_column}>[]' value='%no%'>
              <{if $item.attr_required eq 'true'}>
              <input type='hidden' class='_x_ipt' vtype='selectc'/>
              <{/if}>
              <{/if}>
              
              
              <{if $item.attr_type == 'text'}>
              <input type='text' name=<{$item.attr_column}>
              value='<{$item.attr_value}>' vtype='<{if $item.attr_required eq 'true'}>required&&<{/if}><{$item.attr_valtype}>' />
              <{/if}>
              
              <{if $item.attr_type == 'number'}>
              <input type='text' name=<{$item.attr_column}>
              value='<{$item.attr_value}>' vtype='<{if $item.attr_required eq 'true'}>required&&<{/if}><{$item.attr_valtype}>' />
              <{/if}>
              
              <{if $item.attr_type == 'alpha'}>
              <input type='text' name=<{$item.attr_column}>
              value='<{$item.attr_value}>' vtype='<{if $item.attr_required eq 'true'}>required&&<{/if}><{$item.attr_valtype}>' />
              <{/if}> </div>
          </li>
          <{/foreach}>  
          
          <{if $env.conf.b2c.site.register_valide eq 'true'}>
          <li>
            <label><i>*</i><{t}>验证码：<{/t}></label>
            <div class="floatdiv"><{input vtype="number&&required" size="4" maxlength="4" name="signupverifycode" id="iptsingup"}> <span class='verifyCode' style='display:none;'><img src="#" codesrc='<{link app=b2c ctl="site_passport" act="verifyCode" arg0="s"}>' border="1" /><a href="javascript:void(0)">&nbsp;<{t}>看不清楚?换个图片<{/t}></a> </span></div>
          </li>
          <{/if}>
          <li>
            <label></label>
            <div class="floatdiv"><span  style="width:auto; text-align:left; font-weight:normal;">
              <input type="checkbox" id="license" name="license" value="agree" checked="checked"/>
              <{t}>我已阅读并同意 <{/t}><a href="<{link app='content' ctl=site_article act=index arg0=16}>" id="terms_error" class="lnk" target='_blank'><span class="FormText" id="terms_error_sym"><{t}>会员注册协议<{/t}></span></a><{t}>和<{/t}><a href="<{link app='content' ctl=site_article act=index arg0=17}>" id="privacy_error" class="lnk" target='_blank'><span class="FormText" id="privacy_error_sym"><{t}>隐私保护政策<{/t}></span></a>。 </span></div>
          </li>
          <li>
            <label></label>
            <div class="floatdiv">
              <input class="actbtn btn-register" type="submit" value="<{t}>注册新用户<{/t}>" />
              <input type="hidden" name="forward" value="<{$forward}>">
            </div>
          </li>
        </ul>
        <!--<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <th><i>*</i><{t}>用户名：<{/t}></th>
            <td><input type="text" class="inputstyle _x_ipt" name="pam_account[login_name]" vtype="required"  id="reg_user" maxlength="50" onchange="nameCheck(this)"><span></span></td>
          </tr>
          <tr>
            <th><i>*</i><{t}>密码：<{/t}></th>
            <td><{input class="inputstyle" name="pam_account[login_password]" type="password" vtype="required" id="reg_passwd"}></td>
          </tr>
          <tr>
            <th><i>*</i><{t}>确认密码：<{/t}></th>
            <td><{input class="inputstyle" name="pam_account[psw_confirm]" type="password" vtype="required" id="reg_passwd_r"}></td>
          </tr>
          <tr>
            <th><i>*</i><{t}>电子邮箱：<{/t}></th>
            <td><{input vtype="email&&required"  name="contact[email]" id="reg_email" class="inputstyle _x_ipt" onchange="emailCheck(this)"}><span></span>
           </td>
          </tr>
          
  <{foreach from=$attr item=item name="item" key='row'}>
  <tr>
  <th><{if $item.attr_required eq 'true'}><em>*</em><{/if}><{$item.attr_name}></th>
  <td>  
      
 <{if $item.attr_type =='date'}>
   <{if $item.attr_value != '0-0-0'}>
   <{if $item.attr_required eq 'true'}>
    <{input class="cal" type='date' vtype="required&&date" name=$item.attr_column value=$item.attr_value}>
    <{else}>
     <{input class="cal" type='date' name=$item.attr_column value=$item.attr_value}>
    <{/if}>
    <{else}>
    <{if $item.attr_required eq 'true'}>
      <{input class="cal" type="date" vtype="required&&date" name=$item.attr_column}>
      <{else}>
         <{input class="cal" vtype="date" name=$item.attr_column}>
      <{/if}>
      <{/if}>
  <{/if}>
  
   <{if $item.attr_type =='region'}>
   <{input app=ectools type="region" name=$item.attr_column value=$item.attr_value }>
   <{/if}>
   
   <{if $item.attr_type =='gender'}>
    <{input type='gender' name=$item.attr_column value=$item.attr_value }>
   <{/if}>
   
      <{if $item.attr_type =='select'}>
 <select name='<{$item.attr_column}>' <{if $item.attr_required eq 'true'}>class='_x_ipt' vtype='required'<{/if}>>
   <option value='' <{if $item.attr_value == ''}>selected='true'<{/if}>><{t}>请选择<{/t}></option>
 <{foreach from=$item.attr_option item=option name="option"}>
 <option value='<{$option}>' <{if $item.attr_value == $option}>selected='true'<{/if}>><{$option}></option>
 <{/foreach}>

 </select>
   <{/if}>
   
  <{if $item.attr_type =='checkbox'}>
  <{foreach from=$item.attr_option item=checkbox name="checkbox" }>

 
 
 <input type='checkbox' name=box:<{$item.attr_column}>[]" value='<{$checkbox}>' <{foreach from=$item.attr_value item=checkboxvalue name="checkboxvalue" }>
 <{if $checkboxvalue==$checkbox}>
 checked ='true' 
 <{/if}>
 <{/foreach}>><label><{$checkbox}></label><br/>
   <{/foreach}><input type='hidden' name='<{$item.attr_column}>[]' value='%no%'>

<{if $item.attr_required eq 'true'}><input type='hidden' class='_x_ipt' vtype='selectc'/>
<{/if}>
   <{/if}>
   
   
   <{if $item.attr_type == 'text'}>
     <input type='text' name=<{$item.attr_column}> value='<{$item.attr_value}>' vtype='<{if $item.attr_required eq 'true'}>required&&<{/if}><{$item.attr_valtype}>' />
   <{/if}>
   
    <{if $item.attr_type == 'number'}>
    <input type='text' name=<{$item.attr_column}> value='<{$item.attr_value}>' vtype='<{if $item.attr_required eq 'true'}>required&&<{/if}><{$item.attr_valtype}>' />
   <{/if}>

  <{if $item.attr_type == 'alpha'}>
   <input type='text' name=<{$item.attr_column}> value='<{$item.attr_value}>' vtype='<{if $item.attr_required eq 'true'}>required&&<{/if}><{$item.attr_valtype}>' />
   <{/if}>

</td>
  </tr>
  <{/foreach}>  
          
          <{if $env.conf.b2c.site.register_valide eq 'true'}>
          <tr>
            <th><i>*</i><{t}>验证码：<{/t}></th>
            <td><{input vtype="number&&required" size="4" maxlength="4" name="signupverifycode" id="iptsingup"}>
                <span class='verifyCode' style='display:none;'><img src="#" codesrc='<{link app=b2c ctl="site_passport" act="verifyCode" arg0="s"}>' border="1" /><a href="javascript:void(0)">&nbsp;<{t}>看不清楚?换个图片<{/t}></a>
               </span>
             </td>
          </tr>
          <{/if}>
          <tr>
            <th></th>
            <td><label for="license" class="nof" style="width:auto; text-align:left; font-weight:normal;">
          <input type="checkbox" id="license" name="license" value="agree" checked="checked"/>
          <{t}>我已阅读并同意 <{/t}><a href="<{link app='content' ctl=site_article act=index arg0=16}>" id="terms_error" class="lnk" target='_blank'><span class="FormText" id="terms_error_sym"><{t}>会员注册协议<{/t}></span></a><{t}>和<{/t}><a href="<{link app='content' ctl=site_article act=index arg0=17}>" id="privacy_error" class="lnk" target='_blank'><span class="FormText" id="privacy_error_sym"><{t}>隐私保护政策<{/t}></span></a>。
          </label></td>
          </tr>          
          <tr>
            <th></th>
            <td>
        <input class="actbtn btn-register" type="submit" value="<{t}>注册新用户<{/t}>" />
        <input type="hidden" name="forward" value="<{$forward}>">
              </td>
          </tr>
        </table>-->
        <{$redirectInfo}> </div>
    </div>
  </form>
  <{if $mini_passport}>
  <li>
    <label></label>
    <div class="floatdiv"><{t}>已有帐号？现在<{/t}><a class="link" href="<{link app="b2c" ctl="site_passport" act="login" mini_passport=1}>"><{t}>登陆<{/t}></a></div>
  </li>
  <{/if}> </div>
<{if $valideCode}>
<script>
   void function(formclz){
         var vcodeBox = $E('.'+formclz+' .verifyCode');
         var vcodeImg  =vcodeBox.getElement('img');
         var refreshVcodeBtn  = vcodeBox.getElement('a').addEvent('click',function(e){
              e.stop();
              vcodeImg.src = vcodeImg.get('codesrc')+'?'+$time();
         });
         $$('.'+formclz+' input').addEvent('focus',function(){
             if (this.form.retrieve('showvcode',false))return;
             vcodeBox.show();
             refreshVcodeBtn.fireEvent('click',{stop:$empty});
             this.form.store('showvcode',true);
         });
            $E('.'+formclz+'').addEvent('submit',function(e){
                 var str=$("reg_user").value.trim();
                var len = 0;  
                for (var i = 0; i < str.length; i++) {  
                    str.charCodeAt(i) > 255? len += 2:len ++;  
                }             
                if(len<3)return false;
         });
   }('signupform');
</script>
<{/if}>
<script>
function nameCheck(input){

  new Request.HTML({
	url:'<{link app=b2c ctl=site_passport act=namecheck}>',
	update:$(input).getNext(),
	method:'post',
	data:'name='+encodeURIComponent(input.value=input.value.trim())
	}).send();
}

function emailCheck(input){
  new Request.HTML({
	url:'<{link app=b2c ctl=site_passport act=emailcheck}>',
	update:$(input).getNext(),
	method:'post',
	data:'email='+encodeURIComponent(input.value=input.value.trim())
	}).send();
}

(function(){
	var input = $(document.body).getElements('input[name=contact[area]]')[0];
	var select = input.getNext('select');
	select.addEvent('change',function(e){
		if($(e.target).value !='_NULL_'){
			input.getParent('span').set('vtype','area');
		}
		else{
			input.getParent('span').set('vtype','');
		}
	});
})();
</script>
